

function addSensorbitCod(Blockly) {





    //震动传感器模块
  Blockly.Python.microbit_shock = function(block) {
    var dropdown_shockDigital = this.getFieldValue('shockDigital');
    var dropdown_shockeAnalog = this.getFieldValue('shockAnalog');
    var dropdown_shockValue = this.getFieldValue('shockValue');
    Blockly.Python.definitions_['import_microbit'] = 'from microbit import *';
    Blockly.Python.definitions_['import_Shock'] = 'from sensor import Shock';
    var code = "";
    if(dropdown_shockValue === "1"){
      code = "Shock.read_digital("+dropdown_shockDigital+")";
    }else if(dropdown_shockValue === "2"){
      code = "Shock.read_analog("+ dropdown_shockeAnalog +")";
    }
    return [code];
  }

  //获取震动的模拟值
  Blockly.Python.microbit_shockAnalog = function(block) {
    Blockly.Python.definitions_['import_microbit'] = 'from microbit import *';
    Blockly.Python.definitions_['import_shock'] = 'from sensor import shock';
    var dropdown_shockAnalog = this.getFieldValue('shockAnalog');
    Blockly.Python.definitions_['import_shockAnalog' + dropdown_shockAnalog] = 'shockAnalog' + dropdown_shockAnalog + ' = ' + dropdown_shockAnalog;
    var code = "shock.get_value(shockAnalog" + dropdown_shockAnalog + ")";
    return [code];
  }
  
  //  获取震动的数字值
  Blockly.Python.microbit_shockDigital = function(block) {
    Blockly.Python.definitions_['import_microbit'] = 'from microbit import *';
    Blockly.Python.definitions_['import_shock'] = 'from sensor import shock';
    var dropdown_shockDigital = this.getFieldValue('shockDigital');
    Blockly.Python.definitions_['import_shockDigital' + dropdown_shockDigital] = 'shockDigital' + dropdown_shockDigital + ' = ' + dropdown_shockDigital;
    var code = "shock.is_shocks(shockDigital" + dropdown_shockDigital + ")";
    return [code];
  }

    return Blockly;
}

module.exports = addSensorbitCod;

